﻿#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QFileDialog>
#include <QAxObject>
#include <QAxWidget>
#include <QMessageBox>
#include <QTcpServer>
#include <QTcpSocket>
#include <QTimer>

#include "tcpclient.h"
#include "tcpserver.h"
#include "playercontroller.h"
#include "commonmessage.h"

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
public slots:
    void onRecvNewMsg(MesSource source, CommonMessage msg);
protected:
    void closeEvent(QCloseEvent *event);

private slots:
    void on_btn_Listen_clicked();
    void on_btn_FullScreen_clicked();
    void on_btn_Send_clicked();
    void on_btn_Close_clicked();
    void on_btn_Connect_clicked();
    void on_btn_sync_clicked();
    void onOpenFile();
    void onTimeOut();
private:
    Ui::MainWindow *ui;
    TcpClient *client;
    TcpServer *server;
    TcpBase *tcpCommon;
    PlayerController *player;
    QTimer * timer;

    void InitUI();
    void connectToHostAsClient();
    void disconnectToHostAsClient();
    void startListenAsServer();
    void stopListenAsServer();
    void acceptConnectionAsServer();
    void disConnectionAsServer();
    void printCommonLog(QString log, QString type = "INFO");
    void disConnectionAsClient();
    void setPeerMediaInfo(QString msg);
};
#endif // MAINWINDOW_H
